@extends('layout')
@section('script')
	{{ HTML::script('js/ajax.js') }}
	{{ HTML::script('js/estilos.js') }}
@stop
@section('content')
	<div class="row">
{{--*/$json = Ganado::where('activo','1')->where('id_estado','!=','2')->where('id_estado','!=','4')->orderby('id','DESC')->get();
$jsonencoded = json_encode($json,JSON_UNESCAPED_UNICODE);

$fh = fopen("datos.json", 'w+');
fwrite($fh, $jsonencoded);
fclose($fh);
/*--}}


<table id="dev-table" data-toggle="table" data-url="http://localhost/sysganadero/public/datos.json" data-cache="false" data-height="299" data-click-to-select="true">
    <thead>
        <tr>
            <th data-field="state" data-checkbox="true"></th>
            <th data-field="id">Item ID</th>
            <th data-field="cod_ganado">Cod Ganado</th>
            <th data-field="sexo">Sexo</th>
            <th data-field="id_raza">Raza</th>
            <th data-field="id_tipo">Tipo</th>
        </tr>
    </thead>
</table>

 {{ Form::submit('vendo',array('class' => 'btn-small btn-primary', 'onClick' => 'Dataselect()')) }}



        <div class="dual-list list-left col-md-6">
            <div class="well text-right">
                <div class="row">
                    <div class="col-md-11">
                        <div class="input-group">
                            <span class="input-group-addon glyphicon glyphicon-search"></span>
                            <input type="text" name="SearchDualList" class="form-control" placeholder="Buscar" />
                        </div>
                    </div>
                    <div class="">
                        <div class="btn-group">
                            <a class="btn btn-default selector" title="select all"><i class="glyphicon glyphicon-unchecked"></i></a>
                        </div>
                    </div>
                </div>
                <ul class="list-group">
                	@foreach(Ganado::where('activo','1')->where('id_estado','!=','2')->where('id_estado','!=','4')->orderby('id','DESC')->get() as $ganado)
                    <li class="list-group-item">

		    			<td id="id"><strong>{{$ganado -> id}}</strong></td>
		    			<td id="cod_ganado">{{$ganado -> cod_ganado}}</td>
		    			<td id="sexo">{{$ganado -> sexo}}</td>
		    			<td id="color">{{$ganado -> color}}</td>
		    			<td id="raza">{{$ganado->id_raza}}</td>
		    			<td id="tipo">{{$ganado ->id_tipo}}</td>
		    			{{--<td id="fechanaci">{{$ganado -> fecha_nacimiento}}</td>--}}
		    			<td id="madre">{{$ganado -> cod_madre}}</td>
		    			<td id="padre">{{$ganado -> cod_padre}}</td>
		    			<td>

		    				<a href="{{route('ganado.show',$ganado->id)}}" class="btn btn-info btn-xs">Ver</a>
		    	
		    			</td>  	
                    </li>
                    @endforeach
                </ul>
            </div>
        </div>

        <div class="list-arrows col-md-1 text-center">
            <button class="btn btn-default btn-sm move-left">
                <span class="glyphicon glyphicon-chevron-left"></span>
            </button>

            <button class="btn btn-default btn-sm move-right">
                <span class="glyphicon glyphicon-chevron-right"></span>
            </button>
        </div>

        <div class="dual-list list-right col-md-5">
            <div class="well">
                <div class="row">
                    <div class="col-md-2">
                        <div class="btn-group">
                            <a class="btn btn-default selector" title="selecciona todos"><i class="glyphicon glyphicon-unchecked"></i></a>
                        </div>
                    </div>
                    <div class="col-md-10">
                        <div class="input-group">
                            
                        </div>
                    </div>
                </div>
                <ul class="list-group">

                </ul>
                {{-- */$datos = 10;/* --}}
            </div>
            
        </div>

	</div>




<script type="text/javascript">
$(function () {

            $('body').on('click', '.list-group .list-group-item', function () {
                $(this).toggleClass('active');
            });
            $('.list-arrows button').click(function () {
                var $button = $(this), actives = '';
                if ($button.hasClass('move-left')) {
                    actives = $('.list-right ul li.active');
                    actives.clone().appendTo('.list-left ul');
                    actives.remove();
                } else if ($button.hasClass('move-right')) {
                    actives = $('.list-left ul li.active');
                    actives.clone().appendTo('.list-right ul');
                    actives.remove();
                }
            });
            $('.dual-list .selector').click(function () {
                var $checkBox = $(this);
                if (!$checkBox.hasClass('selected')) {
                    $checkBox.addClass('selected').closest('.well').find('ul li:not(.active)').addClass('active');
                    $checkBox.children('i').removeClass('glyphicon-unchecked').addClass('glyphicon-check');
                } else {
                    $checkBox.removeClass('selected').closest('.well').find('ul li.active').removeClass('active');
                    $checkBox.children('i').removeClass('glyphicon-check').addClass('glyphicon-unchecked');
                }
            });
            $('[name="SearchDualList"]').keyup(function (e) {
                var code = e.keyCode || e.which;
                if (code == '9') return;
                if (code == '27') $(this).val(null);
                var $rows = $(this).closest('.dual-list').find('.list-group li');
                var val = $.trim($(this).val()).replace(/ +/g, ' ').toLowerCase();
                $rows.show().filter(function () {
                    var text = $(this).text().replace(/\s+/g, ' ').toLowerCase();
                    return !~text.indexOf(val);
                }).hide();
            });

        });
</script>
@stop
@section('modal')
	

<div class="modal lg" id="myModal">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Cerrar</span></button>
        <h4 class="modal-title">Seleccion de Ganado</h4>
      </div>
      <div class="modal-body">
        <div class="container" style="margin-top:10px">
    	<div class="row">
			<div class="col-md-9">
				<div class="panel panel-primary">
					<div class="panel-heading">
						<h3 class="panel-title">Ganado Disponible para la Venta</h3>
						<div class="pull-right">
							<span class="clickable filter" data-toggle="tooltip" title="Toggle table filter" data-container="body">
								<i class="glyphicon glyphicon-filter"></i>
							</span>
						</div>
					</div>
					<div class="panel-body">
						<input type="text" class="form-control" id="dev-table-filter" data-action="filter" data-filters="#dev-table" placeholder="Filtrar Ganado" />
					
					<table class="table table-hover" id="dev-table">
						<thead>
							<tr>
								<th>#</th>
								<th>N° Ganado</th>
					    		<th>Sexo</th>
					    		<th>Color</th>
					    		<th>Raza</th>
					    		<th>Tipo</th>
					    		<th>Nacimiento</th>
					    		<th>N° Madre</th>
					    		<th>N° Padre</th>
					            <th>Ver</th>
							</tr>
						</thead>
						<tbody>
							<?php $x = 0;?>
							@foreach(Ganado::where('activo','1')->where('id_estado','!=','2')->where('id_estado','!=','4')->orderby('id','DESC')->get() as $ganado)
					    		<tr>
					    			<td>{{Form::radio('chck',$ganado->id,false,array('onclick'=>'mostrar()','id'=>'check'+$x))}}</td>
					    			<td id="cod_ganado">{{$ganado -> cod_ganado}}</td>
					    			<td id="sexo">{{$ganado -> sexo}}</td>
					    			<td id="color">{{$ganado -> color}}</td>
					    			<td id="raza">{{$ganado->id_raza}}</td>
					    			<td id="tipo">{{$ganado ->id_tipo}}</td>
					    			<td id="fechanaci">{{$ganado -> fecha_nacimiento}}</td>
					    			<td id="madre">{{$ganado -> cod_madre}}</td>
					    			<td id="padre">{{$ganado -> cod_padre}}</td>
					    			<td>

					    				<a href="{{route('ganado.show',$ganado->id)}}" class="btn btn-info btn-xs">Ver</a>
					    	
					    			</td>
					    		</tr>
					    		<?php $x++;?>
					    	@endforeach

						</tbody>
					</table>
					<input type="text" class="form-control" id="yo" data-action="filter" data-filters="#dev-table" placeholder="Filtrar Ganado" />

					</div>
				</div>
				<div>
					
					
					
					
				</div>
			</div>
		</div>
	</div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
        <button type="button" class="btn btn-primary"id="guardar">Guardar</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

@stop

